Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect allocated storage for container projects #15973

Closed
wants to merge 1 commit into from

Conversation

zeari
Copy link

@zeari zeari commented Sep 14, 2017

Fill in derived_vm_allocated_disk_storage in hourly MetricRollups for container groups and container projects.

@cben @moolitayer @zakiva please review.
cc @simon3z
@miq-bot add_label providers/containers, wip, enhancement, providers/metrics

Edit: Storage for pods was removed from this PR since in the case of many pods using the same pvc, no one specific pod was allocated the entire storage capacity.

@miq-bot miq-bot changed the title Collect allocated storage for container groups and container projects [WIP] Collect allocated storage for container groups and container projects Sep 14, 2017
@@ -0,0 +1,17 @@
module Metric::ContainerStorage
def self.fill_allocated_container_storage(obj)
volumes_or_claims = if obj.kind_of? ContainerGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC @nimrodshn added pod => pvc relation too, so it might be simpler to use it here.

return {} if !obj.kind_of?(ContainerProject)

sum_storage = obj.persistent_volume_claims.inject(0) do |sum, volume|
sum + volume.capacity[:storage] if volume.capacity.present?
Copy link
Author

@zeari zeari Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zakiva should this also check if the pvc is bounded or not?
I think so since only then it would mean that the project was allocated a pv(else its just a request?).

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#lifecycle-of-a-volume-and-claim

Copy link
Contributor

@zakiva zakiva Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to check because capacity represents the actual resources of the bounded volume. In case the claim is not bounded, capacity will be an empty hash.

@zeari
Copy link
Author

zeari commented Sep 25, 2017

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] Collect allocated storage for container groups and container projects Collect allocated storage for container groups and container projects Sep 25, 2017
@miq-bot miq-bot removed the wip label Sep 25, 2017
@zeari zeari changed the title Collect allocated storage for container groups and container projects Collect allocated storage for container projects Sep 25, 2017
@miq-bot
Copy link
Member

miq-bot commented Sep 25, 2017

Checked commit zeari@be3dc46 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 👍


it "calculates container storage when having zero persistent volume claims" do
derived_columns = described_class.fill_allocated_container_storage(project3)
expect(derived_columns[:derived_vm_allocated_disk_storage]).to eq(0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: projects with no pvc's or unbounded pvcs will have zero instead of nil.

@zeari
Copy link
Author

zeari commented Oct 15, 2017

@simon3z Ping

@simon3z
Copy link
Contributor

simon3z commented Oct 20, 2017

@simon3z Ping

@zeari is this working with Claims that were defined only for a fraction of the hour?
Any limitation WRT archived projects? (e.g. if a project is archived will we collect if in its last hour had any Claim? etc.)

Code-wise please get some initial reviews from other CM engineers.

@bazulay
Copy link

bazulay commented Nov 26, 2017

@zeari please update patch to use recently added collected PVC requests.

@zeari
Copy link
Author

zeari commented Nov 26, 2017

@zeari is this working with Claims that were defined only for a fraction of the hour?
Any limitation WRT archived projects? (e.g. if a project is archived will we collect if in its last hour had any Claim? etc.)

No and no, since we dont collect metrics for project directly. AFAIK We have only metric rollups for ContainerProject and not realtime metrics. Without adding realtime metrics for projects, 'end-of-the-hour-data' is as close as I can get.

@zeari
Copy link
Author

zeari commented Dec 25, 2017

Closing until relevant again.

@zeari zeari closed this Dec 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants